<?php
	session_start();
	echo "<h2>Accommodations:</h2>";
	error_reporting (E_ALL ^ E_NOTICE);
	$accommpax = $_GET["accommpax"];
	$accommdest = $_GET["accommdest"];
	$hostname_conn = "127.0.0.1"; 
	$database_conn = "onestoptravelsgdb";
	$username_conn = "admin"; 
	$password_conn = "1stoptravel";
	$db_handle = mysql_connect($hostname_conn, $username_conn, $password_conn);
	if (!db_handle) {
		die("Database connection error");
	} else {
		$db_found = mysql_select_db($database_conn, $db_handle);
		if ($db_found) {
			//if ($accommdest != "") {
				echo "<h3>Results for Pax: " . $accommpax . ", Destination: " . $accommdest . "</h3><br/>";
			//}
			$SQL = "SELECT * FROM accommodations;"; //WHERE area = " . $accommdest;
			$result = mysql_query($SQL);
			if ($result) {
				echo "<ul class=\"thumbnails\">";
				while($row = mysql_fetch_array($result))
				{
					$caption = "Name: " . $row['name'] . "<br/>" .
						"Description: " . $row['description'] . "<br/>" .
						"Address: " . $row['address'] . "<br/>" .
						"Cost: " . $row['mincost'] . " - " . $row['maxcost'] . " (" . $row['currency'] . ")" . "<br/>" .
						"Country: " . $row['country'] . "<br/>" .
						"Area: " . $row['area'] . "<br/>" .
						"Pax: " . $row['minpax'] . " - " . $row['maxpax'] . "<br/>" .
						"Website: " . ($row['url'] == "" ? "NA" : $row['url']) . "<br/>" .
						"Email: " . ($row['email'] == "" ? "NA" : $row['email']) . "<br/>" .
						"Phone: " . ($row['phone'] == "" ? "NA" : $row['phone']) . "<br/>" .
						"Rating: " . $row['rating'] . "<br/><br/>" .
						"<a class=\"btn btn-primary\" href=\"javascript:addtoitinerary(" . $row['id'] . ")\">Add to Plan</a>&nbsp;&nbsp;&nbsp;" .
						"<a class=\"btn\" target=\"_blank\" href=\"" . $row['booking'] . "\">Book now</a><br/>";
					echo "<li class=\"thumbnail resultmain\">" .
							"<div class=\"resultimg\">" .
								"<img src=\"" . $row['thumb'] . "\" width=\"300px\" height=\"200px\" alt=\"" . $row['name'] . "\">" .
								"<h5>" . $row['name'] . "</h5>" .
							"</div>" .
							"<div class=\"resulttext\">" .
								"<p>" . $caption . "</p>" .
							"</div>" .
						"</li>";
				}
				echo "</ul>";
			}
			else {
				echo "No results found";
			}
		}
		else {
			die("Database not found error");
		}
	}
	mysql_close($db_handle);
?>